import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot, RouterStateSnapshot, Routes } from '@angular/router';
import { JhiPaginationUtil } from 'ng-jhipster';

import { UserRouteAccessService } from '../../shared';
import { CollegeMySuffixComponent } from './college-my-suffix.component';
import { CollegeMySuffixDetailComponent } from './college-my-suffix-detail.component';
import { CollegeMySuffixPopupComponent } from './college-my-suffix-dialog.component';
import { CollegeMySuffixDeletePopupComponent } from './college-my-suffix-delete-dialog.component';
import {CollegeMySuffixImportComponent} from "./college-my-suffix-import.component";

@Injectable()
export class CollegeMySuffixResolvePagingParams implements Resolve<any> {

    constructor(private paginationUtil: JhiPaginationUtil) {}

    resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
        const page = route.queryParams['page'] ? route.queryParams['page'] : '1';
        const sort = route.queryParams['sort'] ? route.queryParams['sort'] : 'id,asc';
        return {
            page: this.paginationUtil.parsePage(page),
            predicate: this.paginationUtil.parsePredicate(sort),
            ascending: this.paginationUtil.parseAscending(sort)
      };
    }
}

export const collegeRoute: Routes = [
    {
        path: 'college-my-suffix',
        component: CollegeMySuffixComponent,
        resolve: {
            'pagingParams': CollegeMySuffixResolvePagingParams
        },
        data: {
            authorities: ['ROLE_USER'],
            pageTitle: 'gbSubjectApp.college.home.title'
        },
        canActivate: [UserRouteAccessService]
    },
    {
        path: 'college-my-suffix/import',
        component: CollegeMySuffixImportComponent,
        data:{
            authorities: ['ROLE_USER'],
            pageTitle: 'gbSubjectApp.college.home.title'
        },
        canActivate:[UserRouteAccessService],
    },
    {
        path: 'college-my-suffix/:id',
        component: CollegeMySuffixDetailComponent,
        data: {
            authorities: ['ROLE_USER'],
            pageTitle: 'gbSubjectApp.college.home.title'
        },
        canActivate: [UserRouteAccessService]
    }

];

export const collegePopupRoute: Routes = [
    {
        path: 'college-my-suffix-new',
        component: CollegeMySuffixPopupComponent,
        data: {
            authorities: ['ROLE_USER'],
            pageTitle: 'gbSubjectApp.college.home.title'
        },
        canActivate: [UserRouteAccessService],
        outlet: 'popup'
    },
    {
        path: 'college-my-suffix/:id/edit',
        component: CollegeMySuffixPopupComponent,
        data: {
            authorities: ['ROLE_USER'],
            pageTitle: 'gbSubjectApp.college.home.title'
        },
        canActivate: [UserRouteAccessService],
        outlet: 'popup'
    },
    {
        path: 'college-my-suffix/:id/delete',
        component: CollegeMySuffixDeletePopupComponent,
        data: {
            authorities: ['ROLE_USER'],
            pageTitle: 'gbSubjectApp.college.home.title'
        },
        canActivate: [UserRouteAccessService],
        outlet: 'popup'
    }
];
